//
//  StudentView.m
//  View_1
//
//  Created by 愤怒的振振 on 15-4-15.
//  Copyright (c) 2015年 LiuWeiZhen. All rights reserved.
//

#import "StudentView.h"
#import "UILabel+util.h"
#import "UIButton+util.h"

@interface StudentView ()
{
    UILabel *_label;
}
@end

@implementation StudentView

- (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        _label = [UILabel labelWithFrame:CGRectMake(10, 10, frame.size.width-20, 50) text:@"张三" bgColor:[UIColor yellowColor]];
        [self addSubview:_label];
     
        CGRect rect = CGRectMake(20, 100, 200, 40);
        [self addSubview:[UIButton buttonWithTitle:@"测试block" frame:rect target:self selector:@selector(testBlock:)]];
    }
    return self;
}

- (void)testBlock:(id)sender {
    self.name = @"涛涛";
    _label.text = self.name;
    
    // 告诉rootController
    // self.blockHandler和rootController回传数据
    self.blockHandler(self.name);
}

#pragma mark - dealloc
- (void)dealloc {
    self.name = nil;
    self.blockHandler = nil;
    [super dealloc];
}
@end
